package com.android.svmc.app.mobile.tabmanager;

import android.app.TabActivity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;

import com.android.svmc.app.mobile.activity.R;
import com.android.svmc.app.mobile.util.CommonDefine;

public class TabMain extends TabActivity implements CommonDefine{
	private TabHost tabHost;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    	// TODO Auto-generated method stub
    	super.onCreate(savedInstanceState);
    	this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    	setContentView(R.layout.tab_main);
    	
    	setTabs();
    }

	private void setTabs() {
		tabHost=getTabHost();
		addTab(getString(R.string.tab_story), R.drawable.tabbar_icon_story, StoryActivityGroup.class);
		addTab(getString(R.string.tab_pictures), R.drawable.tabbar_icon_pictures, PictureActivityGroup.class);
		addTab(getString(R.string.tab_profile), R.drawable.tabbar_icon_profiles, ProfileActivityGroup.class);
		addTab(getString(R.string.tab_setting), R.drawable.tabbar_icon_setting, SettingActivityGroup.class);	
	}
	private void addTab(String labelId, int drawableId, Class<?> c) {
		TabHost tabHost = getTabHost();
		Intent intent = new Intent(this, c);
		TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);

		View tabIndicator = LayoutInflater.from(this).inflate(
				R.layout.tab_indicator, getTabWidget(), false);
		TextView title = (TextView) tabIndicator.findViewById(R.id.title);
		Typeface font = Typeface.createFromAsset(this.getAssets(), "font/OpenSans-Bold.ttf");
		title.setTypeface(font);
		title.setText(labelId);
		ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
		icon.setImageResource(drawableId);
		spec.setIndicator(tabIndicator);
		spec.setContent(intent);
		tabHost.addTab(spec);
	}

	

	
    
}
